package com.dayu.web.controller.recovery;

import java.util.List;

import com.dayu.common.annotation.RepeatSubmit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.recovery.domain.RecoveryArrange;
import com.dayu.recovery.service.IRecoveryArrangeService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 打理日志Controller
 * 
 * @author HK
 * @date 2021-04-28
 */
@RestController
@RequestMapping("/recovery/arrange")
public class RecoveryArrangeController extends BaseController
{
    @Autowired
    private IRecoveryArrangeService recoveryArrangeService;

    /**
     * 查询打理日志列表
     */
    @PreAuthorize("@ss.hasPermi('recovery:arrange:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecoveryArrange recoveryArrange)
    {
        startPage();
        List<RecoveryArrange> list = recoveryArrangeService.selectRecoveryArrangeList(recoveryArrange);
        return getDataTable(list);
    }

    /**
     * 导出打理日志列表
     */
    @PreAuthorize("@ss.hasPermi('recovery:arrange:export')")
    @Log(title = "打理日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RecoveryArrange recoveryArrange)
    {
        List<RecoveryArrange> list = recoveryArrangeService.selectArrangeListByExport(recoveryArrange);
        ExcelUtil<RecoveryArrange> util = new ExcelUtil<RecoveryArrange>(RecoveryArrange.class);
        return util.exportExcel(list, "arrange");
    }

    /**
     * 获取打理日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('recovery:arrange:query')")
    @GetMapping(value = "/{arrangeId}")
    public AjaxResult getInfo(@PathVariable("arrangeId") Long arrangeId)
    {
        return AjaxResult.success(recoveryArrangeService.selectRecoveryArrangeById(arrangeId));
    }

    /**
     * 新增打理日志
     */
    @RepeatSubmit
    @PreAuthorize("@ss.hasPermi('recovery:arrange:add')")
    @Log(title = "打理日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecoveryArrange recoveryArrange)
    {
        return toAjax(recoveryArrangeService.insertRecoveryArrange(recoveryArrange));
    }

    /**
     * 修改打理日志
     */
    @PreAuthorize("@ss.hasPermi('recovery:arrange:edit')")
    @Log(title = "打理日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecoveryArrange recoveryArrange)
    {
        return toAjax(recoveryArrangeService.updateRecoveryArrange(recoveryArrange));
    }

    /**
     * 删除打理日志
     */
    @PreAuthorize("@ss.hasPermi('recovery:arrange:remove')")
    @Log(title = "打理日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{arrangeIds}")
    public AjaxResult remove(@PathVariable Long[] arrangeIds)
    {
        return toAjax(recoveryArrangeService.deleteRecoveryArrangeByIds(arrangeIds));
    }
}
